package com.newtouch.bxzs.database.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newtouch.bxzs.common.base.model.RolePositionMap;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 岗位角色Mapper:
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/6 15:09</td>
 * <td>tianshangzhu</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author tianshangzhu
 * @version 1.0.0
 * @since 1.0.0
 */
@Mapper
public interface RolePositionMapMapper extends BaseMapper<RolePositionMap> {
    /**
     * 删除岗位角色中间表中数据
     *
     * @param positionIdList 岗位id
     */
    void deleteByPositionIdBatch(@Param("positionIdList") List<String> positionIdList);


    /**
     * 查询岗位角色表中是否存在该角色
     * @param serviceId 角色id
     * @return Integer
     */
    @Select("SELECT 1 FROM ASSISTANT_ROLE_POSITION_MAP WHERE ROLE_ID = #{serviceId} LIMIT 1")
    Integer checkExistsByRoleId(@Param("serviceId") String serviceId);

    /**
     * 岗位角色表批量插入
     * @param list RolePositionMap集合
     */
    void saveBatch(List<RolePositionMap> list);
}
